Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make pix{Read,Write}MemJp2k work via direct memory access #732

Merged
merged 2 commits into from
Feb 6, 2024

Conversation

atykhyy
Copy link
Contributor

@atykhyy atykhyy commented Feb 5, 2024

On platforms lacking open_memstream(), pix{Read,Write}MemJp2k() worked via a temporary file, but this overhead is unnecessary as openjpeg2000's opj_stream interface allows one to read/write directly from a memory buffer by supplying it with appropriate callbacks. This PR makes pix{Read,Write}MemJp2k() use this more direct mechanism on all platforms.

In addition, since pixReadStreamJp2k() always reads the whole stream into memory when it called fgetJp2kResolution(), this PR saves a bit of compute resources by in effect making pixReadStreamJp2k() into a wrapper for pixReadMemJp2k().

* On platforms lacking open_memstream(), pix{Read,Write}MemJp2k()
  worked via a temporary file, but this overhead is unnecessary
  as openjpeg2000's opj_stream allows one to read/write directly
  from a memory buffer by supplying it with appropriate callbacks.
* This commit makes pix{Read,Write}MemJp2k() use this more direct
  mechanism on all platforms.
* In addition, since pixReadStreamJp2k() always read the whole
  stream into memory when it called fgetJp2kResolution(),
  this commit saves a bit of compute resources by in effect making
  pixReadStreamJp2k() into a wrapper for pixReadMemJp2k().
@DanBloomberg
Copy link
Owner

This is very nice work!
I patched your change and jp2kio_reg passes, so the output files are identical!
Thank you!

@DanBloomberg DanBloomberg merged commit dd31a93 into DanBloomberg:master Feb 6, 2024
10 of 11 checks passed
@atykhyy atykhyy deleted the jp2k-memio branch February 6, 2024 08:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants